<?php

namespace html;

use \html\parser as parser;
use \system\core\execute as execute;

class document extends core\document
{

	static function load($html)
	{
		$parser = parser::load($html);

		$document = new self;
		$document->setHtml($parser->getHtml());

		$validator = new \html\validator();
		$tags = $parser->getTags();
		foreach( $tags as $tag )
		{
			$document->setTag($tag);
		}

		$validator->sanitize_tag_types($document);
		$validator->sanitize_attributes($document);

		$parser->level_tags();
		$validator->check_integrity($document);
		
		$parser->build_relations();


		return $document;
	}

	function __call($name,$args){
		$run = new execute();
		$run->setCallingObject($this);
		return call_user_func_array(array($run,$name), $args);
	}

}

?>
